package com.ruoyi.produce.report.produceAnalysis.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.produce.report.produceAnalysis.domain.ProduceAnalysis;
import com.ruoyi.produce.report.produceAnalysis.domain.ProduceAnalysisCond;
import com.ruoyi.produce.report.produceAnalysis.service.IProduceAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 生产分析
 * 2021.12.31
 */
@RestController
@RequestMapping("/produce/report")
@Api(value = "生产分析模块", tags = "生产分析接口")
public class ProduceAnalysisController extends BaseController {
    @Autowired
    private IProduceAnalysisService analysisService;

    /**
     * 获取生产分析
     * @param cond
     * @return
     */
    @ApiOperation("获取生产分析列表")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody ProduceAnalysisCond cond){
        startPage();
        List<ProduceAnalysis> produceAnalyses = analysisService.selectProduceAnalysis(cond);
        return getDataTable(produceAnalyses);
    }

    /**
     * 查看生产计划的建议
     * @param planSelfId
     * @return
     */
    @ApiOperation("查看生产计划的建议")
    @GetMapping("/advice")
    public AjaxResult searchProductionPlanAdvice(@RequestParam String planSelfId) {
        StringBuffer stringBuffer = analysisService.searchProductionPlanAdvice(planSelfId);
        return AjaxResult.success(stringBuffer);
    }
}
